#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include <windows.h>
#include <dbt.h>
#include <QDir>
#include <QDebug>
#include <QDesktopWidget>
#include <QProcess>
#include <QCheckBox>
#include <QInputDialog>
#include <QFileInfoList>

#include <QMessageBox>
#include <QList>

#include <dialog.h>
#include <aes128.h>
//#include <aes128.cpp>

#if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
#include <QtWidgets>
#endif

namespace Ui {
class MainWindow;
}
static int count=0; //剩余密码输入次数
typedef struct udisk_list{
    QString udisk_path;
    bool is_ready;
    bool is_check;
}udisk_list_t;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    static void file_encrypt(QString FilePath, QString target);
    static void file_decrypt(QString FilePath, QString target);

//User definition
private:


    //udisk
    char FirstDriveFromMask (ULONG unitmask);
    void ScanHD();
    bool nativeEvent(const QByteArray & eventType, void * message, long*result);

    void tableWidget_DevInfo_Init();
    void tableWidget_DevInfo_Update();

    bool fomat_udisk(QString udisk_path);

    void append_log(QString);

    void createEncryptedArea();

    QString MD5(QString password);

    void copyfile(QString newfile_path, QString newfile_at_Upan_path);

    //bool qCopyDirectory(const QDir& fromDir, const QDir& toDir, bool bCoverIfFileExists);
    bool copyRecursively(const QString &srcFilePath,const QString &tgtFilePath);

//User definition slots
private slots:
        void tableWidget_DevIsChecked();

        void on_pushButton_Update_clicked();

        void on_pushButton_Formater_clicked();

        void on_pushButton_Show_clicked();

        void textview_file_changed();

private:
    Ui::MainWindow *ui;

    QVector<udisk_list_t> udisk_lists;
    QVector<QString> file_lists;
    char t[20000];
    char k[17]={'a','f','e','f','4','r','n','5','g','u','b','i','y','e','g','e','k'};
};

#endif // MAINWINDOW_H
